home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / music / 87 / c / numview.c < prev    next >
C/C++ Source or Header  |  1986-12-19  |  2KB  |  66 lines

  1. /*  NUMVIEW.C        Dan Stubbs    12/5/86            */
  2. /* This program loads a number of your choice into each and     */
  3. /* every word of screen memory.  Now you can see a decimal     */
  4. /* number of your choosing displayed as 16 bit words in high     */
  5. /* resolution, or combining bits from 2 consecutive words in     */
  6. /* medium resolution or from 4 consecutive words in low     */
  7. /* resolution.  Inspired by P. I. Nelson's Neoview        */
  8. /* Try some negative numbers, too!                */
  9.  
  10. #include <osbind.h>
  11. #include <stdio.h>
  12.  
  13. char input[10],answer[10];
  14. char message1[] = "Enter an integer to be displayed: ";
  15. char mess2[] = "When finished viewing hit any key..........\n\r";
  16. char question[] = "Do you want to view another number?[Y]";
  17. char dummy[6];
  18. int  *screen;
  19.  
  20. main()
  21. {
  22.   int i,j,number;
  23.   char c = 'y';
  24.  
  25.   Cursconf(0,0);     /* This makes cursor disappear */
  26.  
  27.   screen = (int *) Physbase();   /* This finds address of display screen */
  28.   while ((c != 'n') && (c != 'N'))
  29.   {
  30.     input[0] = 8;  /* This tells Cconrs() how many characters to expect    */
  31.     Cconws(mess2);
  32.     Cconws(message1);
  33.  
  34.     /* The following gets a number from the keyboard that is terminated */
  35.     /* by a carriage return.  Alcyon's scanf() is terminated by a space */
  36.     /* -- not a very standard user interface to my way of thinking    */
  37.  
  38.     Cconrs(input);            /* Gets our number         */
  39.     input[input[1]+2] = '\0';        /* Puts a null termination    */
  40.     for(j=0; j <= input[1]; j=j+1)
  41.     {
  42.        dummy[j]=input[j+2];        /* Puts digits into array for    */
  43.     }                     /* sscanf()            */
  44.     sscanf(dummy,"%d",&number);
  45.  
  46.       {
  47.  
  48.         for(i=1; i < 16000; i=i+1)
  49.           {
  50.             *(screen+i)=number;        /* Write number into screen     */
  51.           }
  52.       }
  53.  
  54.     Bconin(2);                /* Waits for a key press    */
  55.     answer[0] = 7;            /* Once again avoiding scanf()    */
  56.     Cconws(question);
  57.     Cconrs(answer);
  58.     answer[answer[1]+2] = '\0';
  59.     for(j=0; j <= answer[1]; j=j+1)
  60.     {
  61.       dummy[j] = answer[j+2];
  62.     }
  63.     sscanf(dummy,"%s",&c);        
  64.   }
  65. }                     /* The end                     */
  66.